package function;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.util.HashMap;
import java.util.Set;

public class filewrite {
	public boolean write(fileinfo fi,String url) {
		try {
			System.out.println("url:"+url);
			System.out.println("name:"+fi.getName());
			System.out.println("type:"+fi.getType());
			File f=new File(url+"/"+fi.getName()+"."+fi.getType());
			BufferedWriter bw=new BufferedWriter(new FileWriter(f));
			HashMap<Integer, String> a=fi.getContent();
			Set<Integer> b=a.keySet();
			for(int i:b) 
				bw.write(a.get(i)+"\n");
			bw.close();
			return true;
		}catch (Exception e) {
			return false;
		}
	}
}
